/**
 * @author chenwx
 * @description 首页服务类
 * @createTime 2019-11-25 16:53
 */
var indexService = (function () {

    var _className = "indexService"

    var _urlSettings = {
        execOrgFullSync: Global.apiBaseUrl + "/datasync/execOrgFullSync",
        execOrgIncSync: Global.apiBaseUrl + "/datasync/execOrgIncSync",
        execUserFullSync: Global.apiBaseUrl + "/datasync/execUserFullSync",
        execUserIncSync: Global.apiBaseUrl + "/datasync/execUserIncSync",
        pageQuerySyncLog: Global.apiBaseUrl + "/datasync/pageQuerySyncLog"
    }

    /**
     * 执行组织全量同步
     * @param success
     * @param fail
     * @private
     */
    var _execOrgFullSync = function (success, fail) {
        wui.logMethodCalled("_execOrgFullSync", _className)
        wui.logParamValue("success", success)
        wui.logParamValue("fail", fail)

        var ajaxParams = {
            method: "get",
            url: _urlSettings.execOrgFullSync,
            onSuccess: success,
            onError: fail,
            isAddRandomCode: true
        }

        wui.ajax(ajaxParams);
    }

    /**
     * 执行组织增量同步
     * @param success
     * @param fail
     * @private
     */
    var _execOrgIncSync = function (success, fail) {
        wui.logMethodCalled("_execOrgIncSync", _className)
        wui.logParamValue("success", success)
        wui.logParamValue("fail", fail)

        var ajaxParams = {
            method: "get",
            url: _urlSettings.execOrgIncSync,
            onSuccess: success,
            onError: fail,
            isAddRandomCode: true
        }

        wui.ajax(ajaxParams);
    }

    /**
     * 执行用户全量同步
     * @param success
     * @param fail
     * @private
     */
    var _execUserFullSync = function (success, fail) {
        wui.logMethodCalled("_execUserFullSync", _className)
        wui.logParamValue("success", success)
        wui.logParamValue("fail", fail)

        var ajaxParams = {
            method: "get",
            url: _urlSettings.execUserFullSync,
            onSuccess: success,
            onError: fail,
            isAddRandomCode: true
        }

        wui.ajax(ajaxParams);
    }

    /**
     * 执行用户增量同步
     * @param success
     * @param fail
     * @private
     */
    var _execUserIncSync = function (success, fail) {
        wui.logMethodCalled("_execUserIncSync", _className)
        wui.logParamValue("success", success)
        wui.logParamValue("fail", fail)

        var ajaxParams = {
            method: "get",
            url: _urlSettings.execUserIncSync,
            onSuccess: success,
            onError: fail,
            isAddRandomCode: true
        }

        wui.ajax(ajaxParams);
    }

    return{
        urlSettings: _urlSettings,
        execOrgFullSync: _execOrgFullSync,
        execOrgIncSync: _execOrgIncSync,
        execUserFullSync: _execUserFullSync,
        execUserIncSync: _execUserIncSync
    }
})();